package com.zuilapsa.jmc.actions;

import com.zuilapsa.jmc.JmcException;
import com.zuilapsa.jmc.userInterfaces.UserInterfaceSession;

public class ActionExit extends ActionNull {

	public void execute(UserInterfaceSession interfaceSession, String[] args)
			throws JmcException {
		try {
			if (interfaceSession.getLevel().hasParent())
				interfaceSession.getLevel().getParent().execute(interfaceSession,args);
			else {
				interfaceSession.printMessageWarning("Can not exit top level.");
				interfaceSession.printMessageWarning("Use logout to exit console.");
			}
		} catch (JmcException e) {
			interfaceSession.printMessageError(e.getMessage());
		}
	}

	public String getHelpString() {
		return "Exits current level";
	}

}
